//
//  CTFollowCell.m
//  ConstellationTalk_0.1
//
//  Created by riley on 15/5/23.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//
#import "CTHeader.h"
#import "CTDebugManager.h"
#import "UIViewAdditions.h"
#import "CTAppLanguage.h"
#import "CTRequestUtil.h"
#import "CTDeviceFunction.h"
#import "CTDiscoveryItems.h"
#import "CTUser.h"
#import "CTFollowCell.h"

@interface CTFollowCell()<FavourFollowHeadBtnDelegate>
{
    UIView *favHeadView;
    
    UILabel *attentionLabel;
    UIButton *attentionBtn;
    
    UIView *commentView;
    
    UIButton    *headerImageView;
    UIImageView *sexImageView;
    UIImageView *sqcImageView;
    UIButton *picImageView;
    
    UILabel *nameLabel;
    UILabel *sqcLabel;
    UILabel *timeLabel;
    UILabel *describeLabel;
    
    
    UIButton *concernBtn;
    UIButton *favourBtn;
    UIButton * commentBtn;
    UIButton * shareBtn;
    UIButton * moreBtn;
    
    UILabel  *concerLabel;
    UILabel  *favourLabel;
    UILabel  *favCountLabel;
    UIImageView *favImageView;
    UILabel  *bottomLine;
    BOOL favBool;
    BOOL attentionBtnBool;
    int favNumber;
    
    NSMutableArray *favArray;
    CTComment *commentItem;
    CTComment *commentItem1; //= [[CTComment alloc]init];
    CTComment *commentItem2; //= [[CTComment alloc]init];
    CTFollowList *cellItem;
}

@end
@implementation CTFollowCell
@synthesize delegate,listDetaiItme;
- (void)dealloc
{
    listDetaiItme = nil;
    favArray = nil;
    commentItem = nil;
    commentItem1 = nil;
    commentItem2 = nil;
    [favImageView removeFromSuperview];
    favImageView = nil;
    [commentBtn removeFromSuperview];
    commentBtn = nil;
    [shareBtn removeFromSuperview];
    shareBtn = nil;
    [moreBtn removeFromSuperview];
    moreBtn = nil;
    [attentionLabel removeFromSuperview];
    attentionLabel = nil;
    [attentionBtn removeFromSuperview];
    attentionBtn = nil;
    
    [favHeadView  removeFromSuperview];
    favHeadView = nil;
    
    [commentView removeFromSuperview];
    commentView  = nil;
    
    [headerImageView removeFromSuperview ];
    headerImageView = nil;
    [sexImageView removeFromSuperview];
    sexImageView = nil;
    [sqcImageView removeFromSuperview ];
    sqcImageView = nil;
    [picImageView removeFromSuperview];
    picImageView = nil;
    
    [nameLabel removeFromSuperview];
    nameLabel = nil;
    [sqcLabel removeFromSuperview];
    sqcLabel = nil;
    [timeLabel removeFromSuperview];
    timeLabel = nil;
    [describeLabel removeFromSuperview];
    describeLabel = nil;
    [concernBtn removeFromSuperview];
    concernBtn = nil;
    [favourBtn removeFromSuperview];
    favourBtn = nil;
    [concerLabel removeFromSuperview];
    concerLabel = nil;
    [favourLabel removeFromSuperview];
    favourLabel = nil;
    [favCountLabel removeFromSuperview];
    favCountLabel = nil;
    [bottomLine removeFromSuperview];
    bottomLine = nil;
    cellItem = nil;
    delegate = nil;

    [CTDebugManager showDebugLogInfo:@"dealloc : CTUserPublishTableCell Is Removed!!!"];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = CT_HEADER_WHITE_COLOR;
        favNumber = 0;
        [self awakeFromNib];
    }
    return self;
}
- (void)awakeFromNib
{
    //    backGroundView  = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 686)];
    //    backGroundView.backgroundColor = CT_HEADER_WHITE_COLOR;
    //    [self addSubview:backGroundView];
    
    //头像
    headerImageView = [UIButton buttonWithType:UIButtonTypeCustom];
    headerImageView.frame = CGRectMake(10, 25, 45, 45);
    [headerImageView setBackgroundImage:[UIImage imageNamed:@"head"] forState:UIControlStateNormal];
    [headerImageView addTarget:self action:@selector(headImageBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    headerImageView.adjustsImageWhenHighlighted = NO;
    headerImageView.layer.masksToBounds = YES;
    headerImageView.layer.cornerRadius  = 22.5;
    [self addSubview:headerImageView];
    //性别
    sexImageView = [[UIImageView alloc]initWithFrame:CGRectMake(40,headerImageView.origin.y+30, 15, 15)];
    sexImageView.image = [UIImage imageNamed:@"xingbie_female"];//男 male
    [self addSubview:sexImageView];
    //名字
    nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(headerImageView.right+10, 30, CT_HEADER_SCREEN_WIDTH-65-70, 18)];
    nameLabel.font =[UIFont systemFontOfSize:18.0f];
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.textColor = CT_HEADER_BLACK_COLOR;
    [self addSubview:nameLabel];
    //关注按钮
    attentionLabel = [[UILabel alloc]initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH-60, 30, 50, 23)];
    attentionLabel.font = [UIFont systemFontOfSize:13.0];
    attentionLabel.textAlignment = NSTextAlignmentCenter;
    attentionLabel.textColor = CT_HEADER_GREEN_COLOR;
    [self addSubview:attentionLabel];
    attentionLabel.hidden = YES;
    attentionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    attentionBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-60, 30, 50, 23);
    [attentionBtn addTarget:self action:@selector(attentionBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:attentionBtn];
    attentionBtn.hidden = YES;
    
    //认证画师
    sqcImageView = [[UIImageView alloc]initWithFrame:CGRectMake(headerImageView.right+10, nameLabel.bottom+5, 13, 13)];
    sqcImageView.image = [UIImage imageNamed:@"vip"];
    [self addSubview:sqcImageView];
    
    //认证画师Label
    sqcLabel = [[UILabel alloc]initWithFrame:CGRectMake(sqcImageView.right+5, nameLabel.bottom+8, CT_HEADER_SCREEN_WIDTH-65-70-30, 10)];
    sqcLabel.font =[UIFont systemFontOfSize:10.0f];
    sqcLabel.textAlignment = NSTextAlignmentLeft;
    sqcLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_vipLabel" withValue:nil withTable:@"Language"];
    sqcLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    [self addSubview:sqcLabel];
    
    
    //时间
    timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 35, CT_HEADER_SCREEN_WIDTH-20, 12)];
    timeLabel.font =[UIFont systemFontOfSize:12.0f];
    timeLabel.textAlignment = NSTextAlignmentRight;
    timeLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    timeLabel.backgroundColor = [UIColor clearColor];
    timeLabel.text = @"1分钟前";
    timeLabel.hidden = YES;
    [self addSubview:timeLabel];
    //大图
    picImageView = [UIButton buttonWithType:UIButtonTypeCustom];
    picImageView.frame = CGRectMake(0, headerImageView.bottom+13, CT_HEADER_SCREEN_WIDTH, CT_HEADER_SCREEN_WIDTH);
    picImageView.adjustsImageWhenHighlighted = NO;
    picImageView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1.0f];
    [picImageView addTarget:self action:@selector(picImageBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [picImageView setBackgroundImage:[UIImage imageNamed:@"faxianguanzhu"] forState:UIControlStateNormal];
    [self addSubview:picImageView];
    
    
    //描述
    describeLabel = [[UILabel alloc]init];
    describeLabel.font = [UIFont systemFontOfSize:15.0f];
    describeLabel.backgroundColor = [UIColor clearColor];
    describeLabel.textColor =[UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    describeLabel.textAlignment = NSTextAlignmentLeft;
    describeLabel.numberOfLines = 2;
    describeLabel.lineBreakMode = NSLineBreakByCharWrapping;
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"#今天#天气不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀不错呀"];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:15.0]
     
                          range:NSMakeRange(0, 4)];
    //     [AttributedStr addAttribute:NSLinkAttributeName value:aURL range:range];
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:[UIColor colorWithRed:255/255.0 green:134/255.0 blue:49/255.0 alpha:1.0]
     //    从第N个起 的几个字
                          range:NSMakeRange(0, 4)];
    
    describeLabel.attributedText = AttributedStr;
    [self addSubview:describeLabel];
    
    //点赞
    favourBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_dianzan"] forState:UIControlStateNormal];
    [favourBtn addTarget:self action:@selector(favourBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:favourBtn];
    favourLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, 35, 24)];
    favourLabel.font =[UIFont systemFontOfSize:13.0f];
    favourLabel.textAlignment = NSTextAlignmentLeft;
    favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favourLabel_title" withValue:nil withTable:@"Language"];
    favourLabel.textColor = CT_HEADER_BLACK_COLOR;
    [favourBtn addSubview:favourLabel];
    
    //评论
    commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [commentBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_pinglun"] forState:UIControlStateNormal];
    [commentBtn addTarget:self action:@selector(commentBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:commentBtn];
    UILabel * commentLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, 41, 24)];
    commentLabel.font =[UIFont systemFontOfSize:13.0f];
    commentLabel.textAlignment = NSTextAlignmentLeft;
    commentLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title" withValue:nil withTable:@"Language"];
    commentLabel.textColor = CT_HEADER_BLACK_COLOR;
    commentLabel.backgroundColor = [UIColor clearColor];
    [commentBtn addSubview:commentLabel];
    
    //分享
    shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [shareBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_zhuanfa"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(shareBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:shareBtn];
    UILabel * shareLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, 35, 24)];
    shareLabel.font =[UIFont systemFontOfSize:13.0f];
    shareLabel.textAlignment = NSTextAlignmentLeft;
    shareLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_shareLabel_title" withValue:nil withTable:@"Language"];
    shareLabel.textColor = CT_HEADER_BLACK_COLOR;
    shareLabel.backgroundColor = [UIColor clearColor];
    [shareBtn addSubview:shareLabel];
    
    moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [moreBtn setBackgroundImage:[UIImage imageNamed:@"follow_more"] forState:UIControlStateNormal];
    [moreBtn addTarget:self action:@selector(moreBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:moreBtn];
    
    favImageView = [[UIImageView alloc]init];
    favImageView.image = [UIImage imageNamed:@"renshu_dianzanrenshu"];
    [self addSubview:favImageView];
    
    favCountLabel = [[UILabel alloc]init];
    favCountLabel.font =[UIFont systemFontOfSize:15.0f];
    favCountLabel.textAlignment = NSTextAlignmentLeft;
    favCountLabel.text = @"999W";
    favCountLabel.textColor = CT_HEADER_BLACK_COLOR;
    [self addSubview:favCountLabel];
    
    
    favHeadView = [[UIView alloc]init];
    [self addSubview:favHeadView];
    
    commentView = [[UIView alloc]init];
    [self addSubview:commentView];
    
    
    UIImageView *commentImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 15, 13)];
    commentImageView.image = [UIImage imageNamed:@"renshu_pinglunrenshu"];
    [commentView addSubview:commentImageView];
    
    
    
    bottomLine = [[UILabel alloc]init];
    bottomLine.backgroundColor = CT_HEADER_BRIGHTLINE_COLOR;
    [self addSubview:bottomLine];
}



- (void)createFavHeadImageView:(NSMutableArray *) ary
{
    [favHeadView removeAllSubviews];
    DeviceTypeAdaptation  devictType = [CTDeviceFunction deviceTypeForResolutionAdaptation];
    if (devictType == iPhone5_5s_5c ||devictType == iPhone4_4s)
    {
        long count = 0;
        if (ary.count > 6)
        {
            count = 6;
        }
        else
        {
            count = ary.count;
        }
        
        float  jianju =(CT_HEADER_SCREEN_WIDTH-110-180)/5;
        if (ary.count > 0)
        {
            for (int i = 1; i < count+1; i++)
            {
                listDetaiItme = [ary objectAtIndex:count-i];
                FavourFollowHeadBtn * favBtn = [FavourFollowHeadBtn buttonWithType:UIButtonTypeCustom];
                favBtn = [favBtn creatBtn:favBtn];
                favBtn.frame = CGRectMake((i-1)*30+(i-1)*jianju,0,30,30);
                favBtn.delegate = self;
                favBtn.userItem = listDetaiItme;
                [favHeadView addSubview:favBtn];
            }
            
        }
    }
    else
    {
        long count = 0;
        if (ary.count > 8)
        {
            count = 8;
        }
        else
        {
            count = ary.count;
        }
        float  jianju =(CT_HEADER_SCREEN_WIDTH-110-240)/7;
        if (ary.count >0)
        {
            for (int i = 1; i < count+1; i++)
            {
                listDetaiItme = [ary objectAtIndex:count-i];
                
                FavourFollowHeadBtn * favBtn = [FavourFollowHeadBtn buttonWithType:UIButtonTypeCustom];
                favBtn = [favBtn creatBtn:favBtn];
                favBtn.frame = CGRectMake((i-1)*30+(i-1)*jianju,0,30,30);
                favBtn.delegate = self;
                favBtn.userItem = listDetaiItme;
                [favHeadView addSubview:favBtn];
            }
        }
    }
    
}
- (void)commentViewWithArray:(NSArray *) ary
{
    [commentView removeAllSubviews];
    long commentCount = 0;
    if (ary.count >0)
    {
        commentCount = ary.count;
        commentItem1 = [ary objectAtIndex:0];
        if (ary.count >=2)
        {
            commentItem2 = [ary objectAtIndex:1];
            commentCount =2;
        }
    }
    
    UIImageView *commentImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 15, 13)];
    commentImageView.image = [UIImage imageNamed:@"renshu_pinglunrenshu"];
    [commentView addSubview:commentImageView];
    
    UILabel * commentCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(commentImageView.right+5, 0, CT_HEADER_SCREEN_WIDTH-50, 15)];
    commentCountLabel.font =[UIFont systemFontOfSize:15.0f];
    commentCountLabel.textAlignment = NSTextAlignmentLeft;
    commentCountLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    commentCountLabel.backgroundColor = [UIColor clearColor];
    commentCountLabel.text = [NSString stringWithFormat:@"%@%d%@",[CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title_head" withValue:nil withTable:@"Language"],(int)ary.count,[CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title_foot" withValue:nil withTable:@"Language"]];
    [commentView addSubview:commentCountLabel];
    
    UIButton *commentCoountBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    commentCoountBtn.frame = CGRectMake(commentImageView.origin.x, commentImageView.origin.y, commentView.width, 15) ;
    [commentCoountBtn addTarget:self action:@selector(commentCountBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [commentView addSubview:commentCoountBtn];
    
    UIButton *commentImageView1 = [[UIButton alloc]initWithFrame:CGRectMake(35, commentCountLabel.bottom+10, 30, 30)];
    commentImageView1.layer.masksToBounds = YES;
    commentImageView1.layer.cornerRadius  = 15.0f;
    [commentImageView1 addTarget:self action:@selector(commentImageView1BtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [CTRequestUtil requestImgWithUrl:commentItem1.user.profile_image_url_thumb withCompletionSuccessHandler:^(UIImage *img) {
        [commentImageView1 setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
    [commentView addSubview:commentImageView1];
    UILabel *commentLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(commentImageView1.right+10, commentCountLabel.bottom+20, CT_HEADER_SCREEN_WIDTH-73-20, 15)];
    commentLabel1.font =[UIFont systemFontOfSize:15.0f];
    commentLabel1.textAlignment = NSTextAlignmentLeft;
    commentLabel1.text = commentItem1.text;
    commentLabel1.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    commentLabel1.backgroundColor = [UIColor clearColor];
    [commentView addSubview:commentLabel1];
    
    UIButton *comBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    comBtn1.frame = commentLabel1.frame;
    [comBtn1 addTarget:self action:@selector(comBtn1Action:) forControlEvents:UIControlEventTouchUpInside];
    [commentView addSubview:comBtn1];
    
    if (commentCount == 2)
    {
        UIButton *commentImageView2 = [[UIButton alloc]initWithFrame:CGRectMake(35, commentImageView1.bottom+10, 30, 30)];
        commentImageView2.layer.masksToBounds = YES;
        commentImageView2.layer.cornerRadius  = 15.0f;
        [CTRequestUtil requestImgWithUrl:commentItem2.user.profile_image_url_thumb withCompletionSuccessHandler:^(UIImage *img) {
            [commentImageView2 setBackgroundImage:img forState:UIControlStateNormal];
        } withFailedHandler:^(NSError *error) {
            
        }];
        [commentImageView2 addTarget:self action:@selector(commentImageView2BtnAction:) forControlEvents:UIControlEventTouchUpInside];
        //    commentImageView2.backgroundColor = [UIColor redColor];
        [commentView addSubview:commentImageView2];
        
        long commentCount = 0;
        if (ary.count >= 2)
        {
            commentCount =2;
        }
        else
        {
            commentCount = ary.count;
        }
        //    [CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title" withValue:nil withTable:@"Language"];
        
        
        UIButton *commentImageView1 = [[UIButton alloc]initWithFrame:CGRectMake(35, commentCountLabel.bottom+10, 30, 30)];
        commentImageView1.layer.masksToBounds = YES;
        commentImageView1.layer.cornerRadius  = 15.0f;
        [commentImageView1 addTarget:self action:@selector(commentImageView1BtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [commentImageView1 setBackgroundImage:[CTRequestUtil requestImageWithUrl:commentItem1.user.profile_image_url_thumb] forState:UIControlStateNormal];
        [commentImageView1 setBackgroundImage:[CTRequestUtil requestImageWithUrl:commentItem1.user.profile_image_url_thumb] forState:UIControlStateHighlighted];
        [commentView addSubview:commentImageView1];
        UILabel *commentLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(commentImageView1.right+10, commentCountLabel.bottom+20, CT_HEADER_SCREEN_WIDTH-73-20, 15)];
        commentLabel1.font =[UIFont systemFontOfSize:15.0f];
        commentLabel1.textAlignment = NSTextAlignmentLeft;
        commentLabel1.text = commentItem1.text;
        //    [CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title" withValue:nil withTable:@"Language"];
        commentLabel1.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
        commentLabel1.backgroundColor = [UIColor clearColor];
        [commentView addSubview:commentLabel1];
        
        UIButton *comBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
        comBtn1.frame = commentLabel1.frame;
        [comBtn1 addTarget:self action:@selector(comBtn1Action:) forControlEvents:UIControlEventTouchUpInside];
        [commentView addSubview:comBtn1];
        
        if (commentCount == 2)
        {
            UIButton *commentImageView2 = [[UIButton alloc]initWithFrame:CGRectMake(35, commentImageView1.bottom+10, 30, 30)];
            commentImageView2.layer.masksToBounds = YES;
            commentImageView2.layer.cornerRadius  = 15.0f;
            [commentImageView2 setBackgroundImage:[CTRequestUtil requestImageWithUrl:commentItem2.user.profile_image_url_thumb] forState:UIControlStateNormal];
            [commentImageView2 setBackgroundImage:[CTRequestUtil requestImageWithUrl:commentItem2.user.profile_image_url_thumb] forState:UIControlStateHighlighted];
            [commentImageView2 addTarget:self action:@selector(commentImageView2BtnAction:) forControlEvents:UIControlEventTouchUpInside];
            //    commentImageView2.backgroundColor = [UIColor redColor];
            [commentView addSubview:commentImageView2];
            
            
            UILabel *commentLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(commentImageView2.right+10, commentLabel1.bottom+20, CT_HEADER_SCREEN_WIDTH-73-20, 15)];
            commentLabel2.font =[UIFont systemFontOfSize:15.0f];
            commentLabel2.textAlignment = NSTextAlignmentLeft;
            commentLabel2.text = commentItem2.text;
            //        [CTAppLanguage localizedStringForKey:@"fllow_commentLabel_title" withValue:nil withTable:@"Language"];
            commentLabel2.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
            commentLabel2.backgroundColor = [UIColor clearColor];
            [commentView addSubview:commentLabel2];
            
            UIButton *comBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
            comBtn2.frame = commentLabel2.frame;
            [comBtn2 addTarget:self action:@selector(comBtn2Action:) forControlEvents:UIControlEventTouchUpInside];
            [commentView addSubview:comBtn2];
        }
        
    }
}

//点击关注按钮
- (void)attentionBtnAction:(UIButton *) sender
{
    if (attentionBtnBool == NO)
    {
        [attentionBtn setBackgroundImage:[UIImage imageNamed:@"guanzhu_ok_bg"] forState:UIControlStateNormal];
        attentionLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_attentioned_title" withValue:nil withTable:@"Language"];
        attentionLabel.textColor = timeLabel.textColor;
        attentionBtnBool = YES;
    }
    else if ( attentionBtnBool == YES)
    {
        timeLabel.hidden = YES;
        [attentionBtn setBackgroundImage:[UIImage imageNamed:@"guanzhu_bg"] forState:UIControlStateNormal];
        attentionLabel.text =[CTAppLanguage localizedStringForKey:@"fllow_attention_title" withValue:nil withTable:@"Language"];
        attentionLabel.textColor = CT_HEADER_GREEN_COLOR;
        attentionBtnBool = NO;
        
    }
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitAttentionBtnAction:withItem:withBool:)])
    {
        [self.delegate userPublishTableCellHitAttentionBtnAction:self withItem:cellItem withBool:attentionBtnBool];
    }
}

//点击评论总数
- (void)commentCountBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellCommentCountAction:withItem:)])
    {
        [self.delegate userPublishTableCellCommentCountAction:self withItem:commentItem];
    }
}

//点击评论1
- (void)comBtn1Action:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellCommentHitFirstLabelAction:withItem:)])
    {
        [self.delegate userPublishTableCellCommentHitFirstLabelAction:self withItem:commentItem1];
    }
}

//点击评论2
- (void)comBtn2Action:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellCommentHitSecondLabelAction:withItem:)])
    {
        [self.delegate userPublishTableCellCommentHitSecondLabelAction:self withItem:commentItem2];
    }
}
//点击评论头像1
- (void)commentImageView1BtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellCommentHitFirstHeadAction:withItem:)])
    {
        [self.delegate userPublishTableCellCommentHitFirstHeadAction:self withItem:commentItem1];
    }
}
//点击评论头像2
- (void)commentImageView2BtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellCommentHitSecondHeadAction:withItem:)])
    {
        [self.delegate userPublishTableCellCommentHitSecondHeadAction:self withItem:commentItem2];
    }
}

//点击头像
- (void)headImageBtnAction:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitHeadAction:withItem:)])
    {
        [self.delegate userPublishTableCellHitHeadAction:self withItem:cellItem];
    }
}
//点击大图
- (void)picImageBtnAction:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitPicImageBtnAction:withItem:)])
    {
        [self.delegate userPublishTableCellHitPicImageBtnAction:self withItem:cellItem];
    }
}
//点赞
- (void)favourBtnAction:(UIButton *)sender
{
    CTListDetailUser *listItme = [[CTListDetailUser alloc]init];
    listItme.profile_image_url_thumb = [CTUser userInfo].profile_image_url_thumb;
    listItme.name = [CTUser userInfo].name;
    listItme.gender = [CTUser userInfo].gender;
    listItme.uid = [CTUser userInfo].uid;
    
    //需要什么返回值
    if (favBool)
    {
        if(listItme.profile_image_url_thumb != nil)
        {
            for (int i = 0; i < favArray.count; i++)
            {
                CTListDetailUser *userItem = [favArray objectAtIndex:i];
                if ([userItem.uid isEqualToString:listItme.uid])
                {
                    [favArray removeObjectAtIndex:i];
                    break;
                }
                //                [favArray removeObjectAtIndex:favArray.count];
            }
            [self createFavHeadImageView:favArray];
            
            
            [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_dianzan"] forState:UIControlStateNormal];
            favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favourLabel_title" withValue:nil withTable:@"Language"];
            favNumber-=1;
            if (favNumber > 9999)
            {
                favCountLabel.text = [NSString stringWithFormat:@"%dW",favNumber/10000];
            }
            if (favNumber <= 0)
            {
                favCountLabel.text = @"0";
            }
            if (favNumber>0 && favNumber <= 9999)
            {
                favCountLabel.text = [NSString stringWithFormat:@"%d",favNumber];
            }
            favBool = NO;
            
        }
        
    }
    else
    {
        if(listItme.profile_image_url_thumb != nil)
        {
            
            [favArray insertObject:listItme atIndex:favArray.count];
            
            [self createFavHeadImageView:favArray];
            
            
            [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_yizan"] forState:UIControlStateNormal];
            favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favoruLabel_title1" withValue:nil withTable:@"Language"];
            favNumber+=1;
            if (favNumber > 9999)
            {
                favCountLabel.text = [NSString stringWithFormat:@"%dW",favNumber/10000];
            }
            if (favNumber <= 0)
            {
                favCountLabel.text = @"0";
            }
            if (favNumber>0 && favNumber <= 9999)
            {
                favCountLabel.text = [NSString stringWithFormat:@"%d",favNumber];
            }
            favBool = YES;
            
        }
    }
    
    
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitFavourBtnAction:withItem:withBool:)])
    {
        [self.delegate userPublishTableCellHitFavourBtnAction:self withItem:cellItem withBool:favBool];
    }
}

//评论
- (void)commentBtnAction:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitCommentBtnaction:withItem:)])
    {
        [self.delegate userPublishTableCellHitCommentBtnaction:self withItem:cellItem];
    }
}
//分享
- (void)shareBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitShareBtnAction: withItem:)])
    {
        [self.delegate userPublishTableCellHitShareBtnAction:self withItem:cellItem];
    }
}
//更多
- (void)moreBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitMoreBtnAction:withItem:)])
    {
        [self.delegate userPublishTableCellHitMoreBtnAction:self withItem:cellItem];
    }
}
//点赞头像
//- (void)imageViewBtnAction:(UIButton *)sender
//{
//    //需要一个返回值
//    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitFavBtnHeadAction:withItem:)])
//    {
//        [self.delegate userPublishTableCellHitFavBtnHeadAction:self withItem:[favArray objectAtIndex:sender.tag-1000]];
//    }
//}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma  mark -setter-

- (void)setCellItem:(CTFollowList *)item
{
    cellItem = item;
    
    if ([cellItem.user.following isEqualToString:@"1"])
    {
        [self setAttentionBtnBool:YES];
    }
    else
    {
        [self setAttentionBtnBool:NO];
    }
    timeLabel.text = cellItem.update_time;
    //头像
    UIImage * img = [CTRequestUtil requestImageWithUrl:item.user.profile_image_url_thumb];
    if (img == nil)img = [UIImage imageNamed:@"head"] ;
    [headerImageView setBackgroundImage:img forState:UIControlStateNormal];
    //性别
    if ([item.user.gender isEqualToString:@"1"])
    {
        sexImageView.image = [UIImage imageNamed:@"xingbie_male"];
    }
    else if ([item.user.gender isEqualToString:@"2"])
    {
        sexImageView.image = [UIImage imageNamed:@"xingbie_female"];
    }else
    {
        sexImageView.image = nil;
    }
    //名字
    nameLabel.text = item.user.name;
    //大图
    UIImage * picImg = [CTRequestUtil requestImageWithUrl:item.pic_url];
    if (picImg == nil)picImg = [UIImage imageNamed:@"faxianguanzhu"];
    [picImageView setBackgroundImage:picImg forState:UIControlStateNormal];
    if ([item.liked isEqualToString:@"1"])
    {
        favBool = YES;
    }
    else
    {
        favBool = NO;
    }
    if (favBool)
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_yizan"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favoruLabel_title1" withValue:nil withTable:@"Language"];
    }
    else
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_dianzan"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favourLabel_title" withValue:nil withTable:@"Language"];
    }
    
    //点赞总数
    favNumber = [item.like_counts intValue];
    if (favNumber > 9999)
    {
        favCountLabel.text = [NSString stringWithFormat:@"%dW",favNumber/10000];
    }
    if (favNumber <= 0)
    {
        favCountLabel.text = @"0";
    }
    if (favNumber>0 && favNumber <= 9999)
    {
        favCountLabel.text = [NSString stringWithFormat:@"%d",favNumber];
    }
    
    
    
    describeLabel.frame = CGRectMake(10, picImageView.bottom+7.5, CT_HEADER_SCREEN_WIDTH-20, 40);
    favourBtn.frame = CGRectMake(10, describeLabel.bottom+20, 65, 24);
    commentBtn.frame = CGRectMake(favourBtn.right+15, describeLabel.bottom+20, 65, 24);
    shareBtn.frame = CGRectMake(commentBtn.right+15, describeLabel.bottom+20, 65, 24);
    moreBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-34-10, describeLabel.bottom+20, 34, 24);
    favImageView.frame = CGRectMake(10, favourBtn.bottom+32, 15, 15);
    favCountLabel.frame = CGRectMake(30, favourBtn.bottom+34, 50, 15);
    favHeadView.frame = CGRectMake(favCountLabel.right+10, favourBtn.bottom+25, CT_HEADER_SCREEN_WIDTH-110, 30);
    favArray = [NSMutableArray arrayWithArray:item.like_list];
    [self createFavHeadImageView:favArray];
    NSArray *commentAry = item.comment_list;
    if (commentAry.count > 0)
    {
        commentView .hidden  = NO;
        if (commentAry.count >=  2)
        {
            commentView.frame = CGRectMake(0, favCountLabel.bottom+28, CT_HEADER_SCREEN_WIDTH, 27+2*30);
            
        }
        else if(commentAry.count == 1)
        {
            commentView.frame = CGRectMake(0, favCountLabel.bottom+28, CT_HEADER_SCREEN_WIDTH, 27+1*30);
            
        }
        else
        {
            
        }
        [self commentViewWithArray:item.comment_list];
        bottomLine.frame = CGRectMake(0, commentView.bottom+20, CT_HEADER_SCREEN_WIDTH, 0.5);
    }
    else
    {
        commentView .hidden  = YES;
        bottomLine.frame = CGRectMake(0, favHeadView.bottom+20, CT_HEADER_SCREEN_WIDTH, 0.5);
    }
    
    
    self.frame = CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, bottomLine.origin.y+0.5);
}
//认证
- (void)setSqcView:(NSString *)sqcStr
{
    if ([sqcStr isEqualToString:@"1"])
    {
        sqcImageView.hidden = NO;
        sqcLabel.hidden = NO;
    }
    else if([sqcStr isEqualToString:@"0"])
    {
        sqcImageView.hidden = YES;
        sqcLabel.hidden = YES;
    }
}
//点赞按钮
- (void)setFavour:(NSString* )favourStr
{
    if([favourStr isEqualToString:@"1"])
    {
        favBool = YES;
    }
    else
    {
        favBool = NO;
    }
    
    if (favBool)
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_yizan"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favoruLabel_title1" withValue:nil withTable:@"Language"];
    }
    else
    {
        [favourBtn setBackgroundImage:[UIImage imageNamed:@"sangeanniu_dianzan"] forState:UIControlStateNormal];
        favourLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_favourLabel_title" withValue:nil withTable:@"Language"];
    }
}
//名字
- (void)setName:(NSString *) name
{
    nameLabel.text = name;
}
//描述
- (void)setDescribeText:(NSString *)describeText
{
    describeLabel.text = describeText;
}
- (void)buttonAction:(UIButton *)sender
{
    //    if ([self.delegate respondsToSelector:@selector(userPublishTableCellHitTopicBtnAction:withID:)])
    //    {
    //        [self.delegate userPublishTableCellHitTopicBtnAction:self withID:nil];
    //    }
}
//富文本
- (void)setDesRange:(NSRange)desRange
{
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:describeLabel.text];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:15.0]
     
                          range:desRange];
    //    [AttributedStr addAttribute:NSLinkAttributeName value:@"www.baidu.com" range:desRange];
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:[UIColor colorWithRed:255/255.0 green:134/255.0 blue:49/255.0 alpha:1.0]
     //    从第N个起 的几个字
                          range:desRange];
    
    describeLabel.attributedText = AttributedStr;
}
//点赞总数
- (void)setFavourCountLabelText:(int )favCounNumber
{
    favNumber = favCounNumber;
    if (favNumber > 9999)
    {
        favCountLabel.text = [NSString stringWithFormat:@"%dW",favCounNumber/10000];
    }
    if (favNumber <= 0)
    {
        favCountLabel.text = @"0";
    }
    if (favNumber>0 && favNumber <= 9999)
    {
        favCountLabel.text = [NSString stringWithFormat:@"%d",favCounNumber];
    }
    
}
//头像
-(void)setHeadImgUrl:(NSString *)imgUrl
{
    [CTRequestUtil requestImgWithUrl:imgUrl withCompletionSuccessHandler:^(UIImage *img) {
        [headerImageView setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
}
//性别
- (void)setSexStr:(NSString *)sexStr
{
    //    NSLog(@"sexImageStr = %@",sexImgStr);
    if ([sexStr isEqualToString:@"1"])
    {
        sexImageView.image = [UIImage imageNamed:@"xingbie_male"];
    }
    else if ([sexStr isEqualToString:@"2"])
    {
        sexImageView.image = [UIImage imageNamed:@"xingbie_female"];
    }
}
//大图
- (void)setPicImgUrl:(NSString *)picImgUrl
{
    [CTRequestUtil requestImgWithUrl:picImgUrl withCompletionSuccessHandler:^(UIImage *img) {
        [picImageView setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
}
//点赞头像
- (void)setFavHeadImgUrl:(NSArray *)favHeadImgUrlArray
{
    favArray = [NSMutableArray arrayWithArray:favHeadImgUrlArray];
    
    [self createFavHeadImageView:favArray];
}
//是否显示关注按钮
- (void)setAttentionBtnBool:(BOOL)attentionBool
{
    if (attentionBool == YES)
    {
        attentionBtnBool = YES;
        timeLabel.hidden = NO;
        attentionLabel.hidden = YES;
        attentionBtn.hidden = YES;
        //        [attentionBtn setBackgroundImage:[UIImage imageNamed:@"guanzhu_ok_bg"] forState:UIControlStateNormal];
        //        attentionLabel.text = [CTAppLanguage localizedStringForKey:@"fllow_attentioned_title" withValue:nil withTable:@"Language"];
        //        attentionLabel.textColor = timeLabel.textColor;
    }
    if (attentionBool == NO)
    {
        attentionBtnBool = NO;
        timeLabel.hidden = YES;
        attentionBtn.hidden = NO;
        attentionLabel.hidden = NO;
        [attentionBtn setBackgroundImage:[UIImage imageNamed:@"guanzhu_bg"] forState:UIControlStateNormal];
        attentionLabel.text =[CTAppLanguage localizedStringForKey:@"fllow_attention_title" withValue:nil withTable:@"Language"];
        attentionLabel.textColor = CT_HEADER_GREEN_COLOR;
    }
}


@end


@interface CTFllowTabCell()
{
    UIImageView *headImageView;
    UIImageView *sexImageView;
    UILabel     *nameLabel;
    UIImageView *sqcImageView;
    UILabel     *sqcLabel;
    UILabel     *attentionLabel;
    UIButton    *attentionBtn;
}

@end

@implementation CTFllowTabCell

@synthesize delegate,item;

- (void)dealloc
{
    [headImageView removeFromSuperview];
    headImageView = nil;
    [sexImageView removeFromSuperview];
    sexImageView = nil;
    [nameLabel removeFromSuperview];
    nameLabel = nil;
    [sqcImageView removeFromSuperview];
    sqcImageView = nil;
    [sqcLabel removeFromSuperview];
    sqcLabel = nil;
    [attentionLabel removeFromSuperview];
    attentionLabel = nil;
    [attentionBtn removeFromSuperview];
    attentionBtn = nil;
    
    delegate = nil;
    item = nil;
    [CTDebugManager showDebugLogInfo:@"dealloc : CTFllowTableCell Is Removed!!!"];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor greenColor];
        self.frame = CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 111);
        self.backgroundColor = CT_HEADER_WHITE_COLOR;
        //        self.favourBool = YES;
        //        favNumber = 0;
        [self awakeFromNib];
    }
    return self;
}
- (void)awakeFromNib
{
    UILabel * sectionLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 15, CT_HEADER_SCREEN_WIDTH-20, 12)];
    sectionLabel.text  = [CTAppLanguage localizedStringForKey:@"fllow_sectionLabel_text" withValue:nil withTable:@"Language"];
    sectionLabel.font = [UIFont systemFontOfSize:12.0f];
    sectionLabel.textAlignment = NSTextAlignmentLeft;
    sectionLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0f];
    [self addSubview:sectionLabel];
    //头像
    headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, sectionLabel.bottom+10, 45, 45)];
    headImageView.layer.masksToBounds = YES;
    headImageView.layer.cornerRadius  = 22.5f;
    headImageView.image = [UIImage imageNamed:@"head"];
    [self addSubview:headImageView];
    //性别
    sexImageView = [[UIImageView alloc]initWithFrame:CGRectMake(40,headImageView.origin.y+30, 21, 21)];
    sexImageView.image = [UIImage imageNamed:@"female"];//男 male
    [self addSubview:sexImageView];
    //名字
    nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(headImageView.right+10, sectionLabel.bottom+20, CT_HEADER_SCREEN_WIDTH-20, 18)];
    nameLabel.text  = [CTAppLanguage localizedStringForKey:@"fllow_sectionLabel_text" withValue:nil withTable:@"Language"];
    nameLabel.font = [UIFont systemFontOfSize:18.0f];
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.textColor = CT_HEADER_BLACK_COLOR;
    [self addSubview:nameLabel];
    //认证
    sqcImageView = [[UIImageView alloc]initWithFrame:CGRectMake(headImageView.right+10, nameLabel.bottom+5, 13, 13)];
    sqcImageView.image = [UIImage imageNamed:@"v"];
    [self addSubview:sqcImageView];
    
    //认证画师Label
    sqcLabel = [[UILabel alloc]initWithFrame:CGRectMake(sqcImageView.right+5, nameLabel.bottom+8, CT_HEADER_SCREEN_WIDTH-65-70-30, 10)];
    sqcLabel.font =[UIFont systemFontOfSize:10.0f];
    sqcLabel.textAlignment = NSTextAlignmentLeft;
    sqcLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_vipLabel" withValue:nil withTable:@"Language"];
    sqcLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    //    sqcLabel.backgroundColor = [UIColor redColor];
    [self addSubview:sqcLabel];
    
    //关注按钮
    attentionLabel = [[UILabel alloc]initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH-60, 41, 50, 23)];
    attentionLabel.font = [UIFont systemFontOfSize:13.0];
    attentionLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:attentionLabel];
    //    attentionLabel.hidden = YES;
    attentionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    attentionBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-60, 41, 50, 23);
    [attentionBtn addTarget:self action:@selector(attentionBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:attentionBtn];
    [attentionBtn setBackgroundImage:[UIImage imageNamed:@"bt_bg_guanzhu"] forState:UIControlStateNormal];
    attentionLabel.text =[CTAppLanguage localizedStringForKey:@"fllow_attention_title" withValue:nil withTable:@"Language"];
    attentionLabel.textColor = CT_HEADER_ORANGE_COLOR;
    //    attentionBtn.hidden = YES;
    
    //    UILabel *bottomLine = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 0.5)];
    UILabel * bottomLine = [[UILabel alloc]initWithFrame:CGRectMake(0, 111-15.5, CT_HEADER_SCREEN_WIDTH, 0.5)];
    bottomLine.backgroundColor = CT_HEADER_BRIGHTLINE_COLOR;
    [self addSubview:bottomLine];
    
    UILabel * bottomLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 111-15, CT_HEADER_SCREEN_WIDTH, 15)];
    bottomLabel.backgroundColor = [UIColor colorWithRed:250/255.0 green:250/255.0 blue:240/255.0 alpha:1.0];
    [self addSubview:bottomLabel];
    
}

#pragma  mark -setter-

-(void)setName:(NSString *)name
{
    nameLabel.text = name;
}

-(void)setSexStr:(NSString *)sexStr
{
    if ([sexStr isEqualToString:@"1"])
    {
        sexImageView.image = [UIImage imageNamed:@"male"];
    }
    else if ([sexStr isEqualToString:@"2"])
    {
        sexImageView.image = [UIImage imageNamed:@"female"];
    }
}
-(void)setHeadImgUrl:(NSString *)imgUrl
{
    [CTRequestUtil requestImgWithUrl:imgUrl withCompletionSuccessHandler:^(UIImage *img) {
        headImageView.image = img;
    } withFailedHandler:^(NSError *error) {
        
    }];
}
#pragma mark delegate
- (void)attentionBtnAction:(UIButton *) sender
{
    if ([self.delegate respondsToSelector:@selector(followTableCellHitAttentionBtnAction:withItme:)])
    {
        [self.delegate followTableCellHitAttentionBtnAction:self withItme:item];
    }
}

@end






#import "CTDiscoveryItems.h"
@interface FavourFollowHeadBtn()
{
    CTListDetailUser * item;
}

@end


@implementation FavourFollowHeadBtn
@synthesize delegate;

- (void)dealloc
{
    delegate = nil;
}

-(FavourFollowHeadBtn *)creatBtn:(FavourFollowHeadBtn *)btn
{
    [btn addTarget:self action:@selector(btnCliked:) forControlEvents:UIControlEventTouchUpInside];
    btn.frame = CGRectMake(0,0,30,30);
    btn.layer.masksToBounds = YES;
    btn.layer.cornerRadius  = 15;
    [btn setBackgroundImage:[UIImage imageNamed:@"head"] forState:UIControlStateNormal];
    
    return btn;
}

-(void)btnCliked:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(favourHeadBtnClickedAction: withUserItem:)]) {
        [self.delegate favourHeadBtnClickedAction:self withUserItem:item];
    }
}

#pragma mark - setter -

-(void)setListDetailUserItem:(CTListDetailUser *)userItem
{
    item = userItem;
    
    [CTRequestUtil requestImgWithUrl:userItem.profile_image_url_thumb withCompletionSuccessHandler:^(UIImage *img) {
        [self setBackgroundImage:img forState:UIControlStateNormal];
    } withFailedHandler:^(NSError *error) {
        
    }];
}


@end

